home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / utility / 252 / dskpcsrc / deskpac.mod < prev    next >
Text File  |  1988-02-13  |  6KB  |  211 lines

  1. MODULE DeskPac;
  2.  
  3.    (*$S-,$T- turn off stack and range checking *) 
  4.  
  5. (* IMPORT GEMError; -- Only needed if main app... *)
  6. (* IMPORT GEMX;     -- Only needed if main app... *)
  7.  
  8. FROM SYSTEM IMPORT SETREG, ADR, ADDRESS;
  9. IMPORT GEMAESbase;
  10. IMPORT AESApplications;
  11. IMPORT AESEvents;
  12. IMPORT AESForms;
  13. IMPORT AESMenus;
  14. IMPORT AESGraphics;
  15. IMPORT AESResources;
  16. IMPORT AESWindows;
  17. IMPORT Text;
  18. IMPORT Configuration;
  19. IMPORT Resource;
  20. IMPORT Screen;
  21. IMPORT Event;
  22. IMPORT Clock;
  23.  
  24.  
  25. CONST
  26.    StackSize = 10000;
  27.  
  28.    Keyboard = 0;   (* Event Flags *)
  29.    Button   = 1;
  30.    Mouse1   = 2;
  31.    Mouse2   = 3;
  32.    Message  = 4;
  33.    Timer    = 5;
  34.  
  35.    ResourceLoadFailed =
  36.       "[3][ The DeskPac resource file | was not found. The DeskPac | tools are disabled. ][ OK ]";
  37.  
  38.    NoLowResLine1 = "[3][ DeskPac requires that the | screen be in either Medium |";
  39.    NoLowResLine2 = " or High Resolution. The | DeskPac tools are disabled. ][ OK ]";
  40.  
  41.    Failed  = 0;
  42.    Erase   = 0;
  43.    Display = 1;
  44.  
  45. VAR
  46.    Stack           : ARRAY [0..StackSize] OF CARDINAL;
  47.    ExitButton      : INTEGER;
  48.    AccessoryActive : BOOLEAN;
  49.    MsgBuffer       : ARRAY [0..7] OF INTEGER;
  50.    WhichEvent      : BITSET;
  51.    MouseCoordinate : Screen.PixelCoordinate;
  52.    MouseButton     : INTEGER;
  53.    ModifierKey     : INTEGER;
  54.    Key             : INTEGER;
  55.    Clicks          : INTEGER;
  56.    WindowId        : INTEGER;
  57.    WhichMessage    : INTEGER;
  58.    NotUsed         : INTEGER;
  59.    Events          : INTEGER;
  60.    Buffer          : ARRAY [0..160] OF CHAR;
  61.    Success         : BOOLEAN;
  62. (* MenuAddress     : ADDRESS;                  -- Only needed if main app... *)
  63. (* BombOff         : GEMX.ErrorProcessorType;  -- Only needed if main app... *)
  64.  
  65.  
  66. (* Only needed if main app...
  67. PROCEDURE SaveTheWorld;
  68. BEGIN
  69.    AESWindows.WindowUpdate ( GEMAESbase.EndUpdate );
  70.    AESApplications.ApplExit;
  71.    BombOff;
  72. END SaveTheWorld;  
  73. *)
  74.  
  75.  
  76. BEGIN
  77.    SETREG ( 15, ADR ( Stack[StackSize] ) );  (* If main app, then comment out this line *)
  78.  
  79. (* Only needed if main app...
  80. BombOff := GEMX.ErrorProcessor;
  81. GEMX.ErrorProcessor := SaveTheWorld;
  82. *)
  83.  
  84.    (*---- Initialize application --------------------------------------*)
  85.  
  86.    Resource.ApplicationId := AESApplications.ApplInitialise ();
  87.    Event.AccessoryMenuId  := AESMenus.MenuRegister (   (* If main app, then comment *)
  88.       Resource.ApplicationId, "  DeskPac Plus " );     (* ...out these two lines.   *)
  89.    Screen.Open ();
  90.    Configuration.LoadDefault;
  91.  
  92.    (*---- Load the DeskPac resource file -------------------------------*)
  93.  
  94.    IF Screen.Resolution = Screen.LowRes THEN
  95.       Text.Assign ( NoLowResLine1, Buffer );
  96.       Success := Text.ConcatString ( Buffer, NoLowResLine2, Buffer );
  97.       ExitButton      := AESForms.FormAlert ( 1, Buffer );
  98.       AccessoryActive := FALSE;
  99.       Events          := GEMAESbase.MesageEvent;
  100.    ELSE
  101.       IF Screen.Resolution = Screen.MediumRes THEN
  102.          AESResources.ResourceLoad ( Configuration.ColorResource );
  103.       ELSE
  104.          AESResources.ResourceLoad ( Configuration.MonochromeResource );
  105.       END;
  106.       IF GEMAESbase.AESCallResult = Failed THEN
  107.          ExitButton      := AESForms.FormAlert ( 1, ResourceLoadFailed );
  108.          AccessoryActive := FALSE;
  109.          Events          := GEMAESbase.MesageEvent;
  110.       ELSE
  111.          AccessoryActive := TRUE; 
  112.          Events          :=
  113.             GEMAESbase.KeyboardEvent +
  114.             GEMAESbase.ButtonEvent +
  115.             GEMAESbase.MesageEvent +
  116.             GEMAESbase.Mouse1Event +                   (* 6/6/87 - SMN *)
  117.             GEMAESbase.TimerEvent;
  118.          Event.Initialize;
  119.  
  120. (* Only needed if main app...
  121. AESResources.ResourceGetAddr ( GEMAESbase.RTree, Resource.MENU, MenuAddress );
  122. AESMenus.MenuBar ( MenuAddress, 1 );
  123. *)
  124.  
  125.       END;
  126.    END;
  127.  
  128.    (*---- Process events from the user --------------------------------*)
  129.  
  130.    AESGraphics.GrafMouse ( GEMAESbase.Arrow, NIL );
  131.    LOOP
  132.       WhichEvent := BITSET (AESEvents.EventMultiple (
  133.          Events, 
  134.          2,             (* Clicks                    *)
  135.          1,             (* Monitor Left Mouse Button *)
  136.          1,             (* Wait for key pressed      *)
  137.          0, 0, 50, 640, 10,                              (* 6/6/87 - SMN *)
  138.  
  139.          (* The above box serves no purpose other than waking up the *)
  140.          (* accessory ( I hope! ).  We wont even process the event.  *)
  141.          (* This kludge is necessitated bacause of the problems with *)
  142.          (* missing timer events from GEM.                           *)
  143.  
  144.          0, 0,  0,   0,  0, (* Ignore Mouse Box2 *)
  145.          ADR (MsgBuffer),
  146.          Clock.TimerResolution, 0,
  147.          MouseCoordinate.X,
  148.          MouseCoordinate.Y,
  149.          MouseButton,
  150.          ModifierKey,
  151.          Key,
  152.          Clicks ));
  153.  
  154.       AESWindows.WindowUpdate ( GEMAESbase.BeginUpdate );
  155.       AESWindows.WindowGet (
  156.          0,
  157.          GEMAESbase.Top,
  158.          WindowId,
  159.          NotUsed, NotUsed, NotUsed );
  160.  
  161.       IF AccessoryActive THEN
  162.          Event.ProcessTimer;
  163.       END;
  164.         
  165.       IF Message IN WhichEvent THEN
  166.  
  167. (* Only needed if main app...
  168. IF MsgBuffer[0] = GEMAESbase.MenuSelected THEN
  169.   IF MsgBuffer[4] = Resource.MAIN THEN
  170.     MsgBuffer[0] := GEMAESbase.AccessoryOpen;
  171.     MsgBuffer[4] := Event.AccessoryMenuId;
  172.     Event.ProcessMessage ( WindowId, MsgBuffer );
  173.   ELSIF MsgBuffer[4] = Resource.QUIT THEN
  174.     EXIT;
  175.   END;
  176. *)
  177.  
  178.          IF AccessoryActive THEN
  179.             WindowId := MsgBuffer [3];
  180.             Event.ProcessMessage ( WindowId, MsgBuffer );
  181.          ELSIF MsgBuffer[0] = GEMAESbase.AccessoryClose THEN
  182.             (* Ignore the event *)
  183.          ELSE
  184.             ExitButton := AESForms.FormAlert ( 1, ResourceLoadFailed );
  185.          END;
  186.       END;
  187.  
  188.       IF Button IN WhichEvent THEN
  189.          IF AccessoryActive THEN
  190.             Event.ProcessButton ( WindowId, MouseButton, ModifierKey, Clicks );
  191.          END;
  192.       END;
  193.  
  194.       IF Keyboard IN WhichEvent THEN
  195.          IF AccessoryActive THEN
  196.             Event.ProcessKey ( WindowId, Key, ModifierKey );
  197.          END;
  198.       END;
  199.  
  200.       AESWindows.WindowUpdate ( GEMAESbase.EndUpdate );
  201.  
  202.    END (* LOOP *);
  203.  
  204. (* Only needed if main app...
  205. AESWindows.WindowUpdate ( GEMAESbase.EndUpdate );
  206. AESApplications.ApplExit;
  207. *)
  208.  
  209. END DeskPac.
  210.  
  211.